Skip to main content

Switch Statment

Flow-Wing supports the switch keyword to handle multiple cases.

Example Usage:

var a:int = 5
switch true {
  case a > 0 && a < 10:{
      print("a is between 0 and 10")
  }
  case a > 10 && a < 20:{
      print("a is between 10 and 20")
  }
  default: { 
      print("default")
  }
}

Output:

a is between 0 and 10

Here, the switch keyword is used to handle multiple cases.

Example Usage:

var a:int = 5

switch a {
  case 0:{
      print("a is 0")
  } case 1:{
      print("a is 1")
  } case 2:{
      print("a is 2")
  } case 3:{
      print("a is 3")
  } case "Hello":{
      print("a is Hello")
  } default:{
      print("default")
  }
}

Output:

default

Here, the switch keyword is used to handle multiple cases.